package com.imooc.article.service;

import com.imooc.pojo.bo.NewArticleBO;
import com.imooc.utils.PagedGridResult;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Date;

public interface ArticleService {
    /**
     * 用户发文
     * @param newArticleBO
     */
    public void insert(@RequestBody NewArticleBO newArticleBO);

    /**
     * 使用task方法扫描全表数据，实现实现定时发布，不推荐这种方法，建议使用RabbitMQ的定时消息
     */
    void updateOppiontToPublic();

    PagedGridResult articleList(String userId,
                                @RequestParam Integer status,
                                @RequestParam Date startDate,
                                @RequestParam Date endDate,
                                @RequestParam Integer page,
                                @RequestParam Integer pageSize,
                                @RequestParam String keyword);

    void updatearticleStatus(String articleId, Integer status);

    PagedGridResult findAll(@RequestParam Integer status,
                            @RequestParam Integer page,
                            @RequestParam Integer pageSize);

    void deleteArticle(String articleId, String userId);

    void withdrawArticle(String articleId, String userId);

    void updateArticleToGridFs(String articleId, String mongoFileId);

    @Transactional(rollbackFor = RuntimeException.class)
    void updateArticleToPublish(String articleId);
}
